package com.cy.mall.web.front.goods;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cy.mall.comm.constant.Constants;
import com.cy.mall.model.PageBean;
import com.cy.mall.model.Result;
import com.cy.mall.model.query.goods.GoodsListQuery;
import com.cy.mall.model.vo.goods.GoodsDetailVO;
import com.cy.mall.model.vo.goods.GoodsListVO;
import com.cy.mall.model.vo.goods.GoodsRecommendListVO;
import com.cy.mall.model.vo.product.ProductRateVO;
import com.cy.mall.service.goods.GoodsRecommendService;
import com.cy.mall.service.goods.GoodsService;
import com.cy.mall.web.BaseController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 前台-商品
 *
 * @author tanyilin
 *
 * @create 2019年1月24日 下午4:56:32
 */
@RestController
@RequestMapping("/goods")
@Api(tags = "前台-商品")
public class GoodsController extends BaseController {

	@Autowired
	private GoodsRecommendService goodsRecommendService;
	@Autowired
	private GoodsService goodsService;
	
	@ApiOperation("首页商品推荐列表")
	@GetMapping("/get/goods/recommend/list")
	public Result<List<GoodsRecommendListVO>> getGoodsRecommendList() {
		List<GoodsRecommendListVO> list = goodsRecommendService.selectGoodsRecommendList();
		return ok("", list);
	}
	
	@ApiOperation("商品列表")
	@GetMapping("/get/goods/list")
	public PageBean<GoodsListVO> getGoodsList(GoodsListQuery query) {
		PageBean<GoodsListVO> pageBean = goodsService.selectGoodsList(query);
		return pageBean;
	}

	@ApiOperation("商品详情")
	@GetMapping("/get/goods/detail")
	public Result<GoodsDetailVO> getGoodsDetail(@RequestParam(value = "goodsId") Long goodsId) {
		GoodsDetailVO goodsDetailVO = goodsService.selectGoodsDetail(goodsId);
		return ok("", goodsDetailVO);
	}
	
	@ApiOperation("查询对应贷款产品利率数组")
	@GetMapping("/get/product/rate/list")
	public Result<List<ProductRateVO>> getProductRateList() {
		List<ProductRateVO> list = goodsService.selectProductRateList(Constants.JYD_PRODUCTID);
		return ok("", list);
	}

}
